package toy.keli.edic.ui.main.components

import android.content.DialogInterface
import android.os.Process
import android.view.Gravity
import android.widget.Button
import android.widget.LinearLayout
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.AlertDialog
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Colors
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import toy.keli.edic.ui.main.components.Confirm.Companion.showDialog
import toy.keli.edic.ui.main.extend.HtmlView
import toy.keli.edic.ui.main.extend.MText as Text


@Composable
fun PrivacyPolicy(onOk:()->Unit){
    AlertDialog(
        modifier = Modifier.padding(top=10.dp).height(330.dp),
        onDismissRequest = { showDialog = false },
        title = { Text("隐私政策", fontSize = 30.sp) },
        text = {
            HtmlView("欢迎使用“电子词典”，我们非常重视您的隐私保护，在您使用本应用之前，请仔细阅读<a href='https://gitee.com/kelioc/edic/raw/master/blob/pp'>《隐私政策》</a>我们将按照您同意的条款使用您的个人信息，以便为您提供服务。",0.2f,false)
        },
        confirmButton = {
            Button(
                onClick = {
                    onOk()
                    // 执行确认操作
                    showDialog = false
                },
                colors = ButtonDefaults.buttonColors(backgroundColor = Color.Blue)

            ) {
                Text("同意", color = Color.White)
            }
        },
        dismissButton = {
            Button(
                onClick = {
                    // 执行取消操作
                    showDialog = false
                    Process.killProcess(Process.myPid())
                }
                , colors = ButtonDefaults.buttonColors(backgroundColor = Color.Gray)
            ) {
                Text("不同意")
            }
        }
    )
}